import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardAlgorithm {
    public String[] suits={"♣","♦","♠","♥"};
    public List<Card> buyCard(){
        List<Card> list =new ArrayList<>(52);
        for (int i = 1; i <=13; i++) {
            for (int j = 0; j < 4; j++) {
                Card card =new Card();
                card.suit=suits[j];
                card.rank=i;
                list.add(card);
            }
        }
        return list;
    }

    public void shuffle(List<Card> list){
        Random random =new Random();
        for (int i = list.size()-1; i >0 ; i--) {
            int k= random.nextInt(i);
            swap(i,k,list);
        }
    }
    private void swap(int i,int k,List<Card> list){
        Card card =list.get(i);
        list.set(i, list.get(k));
        list.set(k, card);
    }
}
